﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SEO.EmailSearch
{
    public partial class APISetFrm : Form
    {
        SEO.Utility.IniFile iniFile = new Utility.IniFile(Application.StartupPath + "\\config.ini");

        public APISetFrm()
        {
            InitializeComponent();
            skinEngine1.SkinFile = SEO.Utility.CommonHelper.GetCurrentSoftSkin();
            this.Icon = new Icon(SEO.Utility.ICONHelper.SetFormICON());
        }

        private void APISetFrm_Load(object sender, EventArgs e)
        {
            txtSoftPath.Text = iniFile.GetString("BASE", "SoftPath", "");
        }

        private void btnSelect_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fbd = new FolderBrowserDialog();
            if (fbd.ShowDialog() == DialogResult.OK)
            {
                txtSoftPath.Text = fbd.SelectedPath;
            }
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            string strSoftPath = txtSoftPath.Text.Trim();
            if (string.IsNullOrEmpty(strSoftPath))
            {
                MessageBox.Show("请选择软件安装目录！");
            }
            else if (strSoftPath.Contains("data"))
            {
                MessageBox.Show("请选中软件安装目录，不是数据库目录，不包含Data目录在内！");
            }
            else
            {
                iniFile.WriteValue("BASE", "SoftPath", strSoftPath);
                MessageBox.Show("保存成功！");
            }

        }

        private void llblDownload_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            System.Diagnostics.Process.Start("http://www.cloudin.so/software/email-marketing.aspx");
        }
    }
}
